﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;




namespace PongFirstClass
{
    class Objeto2D
    {

        public Texture2D textura;
        public Color cor;
        public Vector2 posicao;
        public Vector2 origem;
        public Vector2 escala;
        public float rotacao;
        public float alpha;
        public bool visible;
        public Rectangle hitBox;
        // camada


        public Objeto2D(Texture2D textura, Vector2 posicao, Color cor)
        {
            this.textura = textura;
            this.posicao = posicao;
            this.cor = cor;
            rotacao = 0;
            origem = new Vector2(textura.Width / 2, textura.Height / 2);
            escala = new Vector2(1, 1);
            visible = true;
            alpha = 1;
            hitBox = new Rectangle((int)posicao.X - textura.Width / 2, (int)posicao.Y - textura.Height / 2, textura.Width, textura.Height);
        }

        public void calcularRetangulo()
        {
            this.hitBox.X = (int)this.posicao.X - textura.Width / 2;
            this.hitBox.Y = (int)this.posicao.Y - textura.Height / 2;
        }

        public bool hitTestObject(Objeto2D objeto)
        {
            return this.hitBox.Intersects(objeto.hitBox);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (visible == true)
            {
                spriteBatch.Draw(textura, posicao, null, cor * alpha, MathHelper.ToRadians(rotacao), origem, escala, SpriteEffects.None, 0.5f);
                //spriteBatch.Draw(textura, hitBox, Color.Blue * 0.5f);
            }

        }










    }
}
